//
//  LZShareViewController.m
//  DoctorFAQs
//
//  Created by langZai on 2017/2/13.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "LZShareViewController.h"

@interface LZShareViewController ()<UITableViewDelegate,UITableViewDataSource>
/** tableView */
@property (nonatomic , strong) UITableView *mainTableView;
/** 图片数组 */
@property (nonatomic , strong) NSArray *imageArray;
/** 标题数组 */
@property (nonatomic , strong) NSArray *titleArray;

@end

static NSString *cellID = @"lz_shareCellID";
@implementation LZShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    [self initializeData];
}


- (void)initializeData {
    _titleArray = @[@"分享到微信",@"分享到QQ",@"分享到微博"];
    _imageArray = @[@"icon_share_weichat",@"icon_share_weichat_QQ",@"icon_share_weibo"];
    self.navigationItem.title = @"分享给好友";
    self.view.backgroundColor = KHColorFromRGB(0xf8f8f8);
}


// 创建tableView
- (void)createTableView {
    if (!_mainTableView) {
        _mainTableView = [[UITableView alloc] init];
        _mainTableView.delegate = self;
        _mainTableView.dataSource = self;
        _mainTableView.rowHeight = 70;
        _mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainTableView.backgroundColor = KHColorFromRGB(0xf8f8f8);
        [self.view addSubview:_mainTableView];
        [_mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.sizeOffset(CGSizeMake(SCREEN_Width, SCREEN_Height - 10));
            make.centerX.equalTo(self.view);
            make.top.equalTo(self.view).offset(10*ysIZE);
        }];
    }
}

#pragma mark - 代理方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        
        // 自定义tableView的分割线
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = KHColorFromRGB(0xe0e0e0);
        [cell.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.sizeOffset(CGSizeMake(355*xsIZE, 0.5*ysIZE));
            make.left.equalTo(cell.mas_left).offset(10*xsIZE);
            make.bottom.equalTo(cell);
        }];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.text = _titleArray[indexPath.row];
        cell.imageView.image = [UIImage imageNamed:_imageArray[indexPath.row]];
        cell.backgroundColor = KHColorFromRGB(0xffffff);
        cell.textLabel.font = NEWFONT(15);
        cell.textLabel.textColor = KHColorFromRGB(0x333333);
        cell.textLabel.textAlignment = NSTextAlignmentLeft;
        if (indexPath.row == 2) {
            lineView.hidden = YES;
        }
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0:
            NSLog(@"分享到微信");
            break;
        case 1:
            NSLog(@"分享到QQ");
            break;
        case 2:
            NSLog(@"分享到微博");
            break;
            
        default:
            break;
    }
}


@end
